--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/marcmere/Box Sync/Shared_EffectofIncarceration_Pennslyvania/Replication Data/Arrests SA Table 06/Arrests.log
  log type:  text
 opened on:  17 Dec 2016, 10:33:20

. 
. clear all 

. set more off

. 
. // Gets distribution of prior arrests. probabation, minor crimes, conditional on no previous conviction
. 
. infix str priorarrests 3179-3181 str probation 3214-3215 /*
> */ str minor1 3363-3367 str major1 3380-3385 str weight 8588-8596 /*
> */ using "04572-0002-Data.txt", clear
(14499 observations read)

. 
. // S6Q1a
. tab priorarrests 

priorarrest |
          s |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      2,359       16.27       16.27
          1 |      2,184       15.06       31.33
         10 |        598        4.12       35.46
         11 |         82        0.57       36.02
         12 |        188        1.30       37.32
         13 |         54        0.37       37.69
         14 |         38        0.26       37.95
         15 |        243        1.68       39.63
         16 |         27        0.19       39.82
         17 |         34        0.23       40.05
         18 |         31        0.21       40.26
         19 |         18        0.12       40.39
          2 |      2,033       14.02       54.41
         20 |        249        1.72       56.13
         21 |         11        0.08       56.20
         22 |         11        0.08       56.28
         23 |         11        0.08       56.36
         24 |         10        0.07       56.42
         25 |         64        0.44       56.87
         26 |         11        0.08       56.94
         27 |          9        0.06       57.00
         28 |         11        0.08       57.08
         29 |          1        0.01       57.09
          3 |      1,557       10.74       67.83
         30 |        129        0.89       68.72
         31 |          7        0.05       68.76
         32 |          8        0.06       68.82
         33 |          4        0.03       68.85
         34 |          3        0.02       68.87
         35 |         19        0.13       69.00
         36 |          6        0.04       69.04
         37 |          1        0.01       69.05
         38 |          3        0.02       69.07
         39 |          1        0.01       69.07
          4 |      1,172        8.08       77.16
         40 |         38        0.26       77.42
         41 |          1        0.01       77.43
         42 |          2        0.01       77.44
         45 |          6        0.04       77.48
         46 |          1        0.01       77.49
         47 |          3        0.02       77.51
         48 |          4        0.03       77.54
          5 |        938        6.47       84.01
         50 |         33        0.23       84.23
         52 |          2        0.01       84.25
         55 |          3        0.02       84.27
          6 |        647        4.46       88.73
         60 |         10        0.07       88.80
         63 |          2        0.01       88.81
         67 |          1        0.01       88.82
          7 |        383        2.64       91.46
         70 |          2        0.01       91.48
         75 |          3        0.02       91.50
          8 |        331        2.28       93.78
         80 |          3        0.02       93.80
         87 |          2        0.01       93.81
          9 |        135        0.93       94.74
         90 |          1        0.01       94.75
         99 |         18        0.12       94.88
        997 |        551        3.80       98.68
        998 |        158        1.09       99.77
        999 |         34        0.23      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. 
. // Categories of Arrests: 0, 1, 2, 3+
. destring priorarrests, force replace
priorarrests contains nonnumeric characters; replaced as int

. gen priorarrests2 = priorarrests

. replace priorarrests2 = 3 if priorarrests >= 3 & priorarrests <= 996
(5623 real changes made)

. tab priorarrests2 

priorarrest |
         s2 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      2,359       16.27       16.27
          1 |      2,184       15.06       31.33
          2 |      2,033       14.02       45.35
          3 |      7,180       49.52       94.88
        997 |        551        3.80       98.68
        998 |        158        1.09       99.77
        999 |         34        0.23      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. 
. /* S6Q2a: Have you ever been placed on probation by a court, either as a
> juvenile or an adult? Include any sentence by a court to both probation 
> and a correctional facility 
> 
> S6Q2b. Have you ever been placed on probation by a court, either as a
> juvenile or an adult, before your probation for (Insert FILL offense)?
> Include any sentence by a court to both probation and a correctional facility. */
. 
. // Prior conviction = 1 if answer is yes to either 
. tab probation

  probation |      Freq.     Percent        Cum.
------------+-----------------------------------
         19 |      7,281       50.22       50.22
         29 |      2,457       16.95       67.16
         79 |         25        0.17       67.34
         89 |         58        0.40       67.74
         91 |      1,694       11.68       79.42
         92 |        709        4.89       84.31
         97 |          5        0.03       84.34
         98 |         11        0.08       84.42
         99 |      2,259       15.58      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. gen priorprobation = (regexm(probation, "1"))

. tab priorprobation

priorprobat |
        ion |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      5,524       38.10       38.10
          1 |      8,975       61.90      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. 
. /* S6Q3a. The following questions are about any times before your admission 
> on (Insert date in Storage Item 2D) that you were sentenced and served time 
> in prison, jail, or another correctional facility.
> 
> ___ Drunkenness? (Exclude DWI and DUI)
> ___ Vagrancy?
> ___ Loitering?
> ___ Disorderly conduct?
> ___ Minor traffic crimes?(Exclude driving while intoxicated and hit and run) */
. 
. tab minor1

     minor1 |      Freq.     Percent        Cum.
------------+-----------------------------------
      11111 |         22        0.15        0.15
      11112 |         13        0.09        0.24
      11121 |          6        0.04        0.28
      11122 |          7        0.05        0.33
      11211 |          6        0.04        0.37
      11212 |          4        0.03        0.40
      11221 |          1        0.01        0.41
      11222 |         10        0.07        0.48
      11721 |          1        0.01        0.48
      12111 |         26        0.18        0.66
      12112 |         17        0.12        0.78
      12121 |          5        0.03        0.81
      12122 |         16        0.11        0.92
      12211 |        143        0.99        1.91
      12212 |        199        1.37        3.28
      12221 |        211        1.46        4.74
      12222 |        653        4.50        9.24
      12271 |          1        0.01        9.25
      21111 |          5        0.03        9.28
      21112 |          5        0.03        9.32
      21121 |          3        0.02        9.34
      21122 |          7        0.05        9.39
      21211 |          1        0.01        9.39
      21212 |          3        0.02        9.41
      21221 |          3        0.02        9.44
      21222 |         15        0.10        9.54
      22111 |         30        0.21        9.75
      22112 |         43        0.30       10.04
      22121 |         41        0.28       10.32
      22122 |        112        0.77       11.10
      22211 |        227        1.57       12.66
      22212 |        495        3.41       16.08
      22221 |      1,073        7.40       23.48
      22222 |      8,747       60.33       83.81
      22227 |          3        0.02       83.83
      22271 |          3        0.02       83.85
      22272 |          2        0.01       83.86
      72222 |          1        0.01       83.87
      77777 |         13        0.09       83.96
      82222 |          1        0.01       83.96
      82288 |          1        0.01       83.97
      88888 |         61        0.42       84.39
      99999 |      2,263       15.61      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. gen priorminor = (regexm(minor1, "1"))

. tab priorminor

 priorminor |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     11,092       76.50       76.50
          1 |      3,407       23.50      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. 
. /* S6Q3c. Before your current admission to prison on 
> (Insert date in Storage Item 2D), were you ever sentenced to serve
> time in prison or jail for ANYTHING other than drunkenness, vagrancy, 
> loitering, disorderly conduct, or minor traffic crimes?
> 
> S6Q3d. Before your sentence for (Insert offense from Storage Item 2B) 
> for which you were admitted to incarceration on 
> (Insert admission date from Storage Item 2D), were you ever sentenced to 
> serve time for ANYTHING other than drunkenness, vagrancy, loitering, 
> disorderly conduct, or minor traffic crimes?
> 
> S6Q3e. Before your sentence for (Insert offense from Storage Item 2E) for which 
> you were admitted to incarceration on 
> (Insert admission date from Storage Item 2F), were you ever sentenced to serve 
> time for ANYTHING other than drunkenness, vagrancy, loitering, disorderly 
> conduct, or minor traffic crimes?
> 
> S6Q3f. Before your sentence to probation for the 
> (Insert offenses from Storage Item 2E) were you ever sentenced to
> serve time for ANYTHING other than drunkenness, vagrancy, loitering, 
> disorderly conduct, or minor traffic crimes?
> 
> S6Q3g. Before your sentence to probation for the 
> (Insert offenses from Storage Item 2B) were you ever sentenced to
> serve time for ANYTHING other than drunkenness, vagrancy, loitering, 
> disorderly conduct, or minor traffic crimes? 
> 
> S6Q3h. Before your admission to prison on (Insert date in Storage Item 2D), 
> were you ever sentenced to serve time for ANYTHING other than drunkenness, 
> vagrancy, loitering, disorderly conduct, or minor traffic crimes? */
. 
. tab major1

     major1 |      Freq.     Percent        Cum.
------------+-----------------------------------
     199999 |         77        0.53        0.53
     299999 |         45        0.31        0.84
     899999 |          1        0.01        0.85
     912999 |          1        0.01        0.86
     919999 |      3,536       24.39       25.24
     922999 |          1        0.01       25.25
     929999 |      3,947       27.22       52.47
     979999 |          7        0.05       52.52
     989999 |         28        0.19       52.71
     991999 |      1,242        8.57       61.28
     992999 |      1,662       11.46       72.74
     997999 |          2        0.01       72.76
     998999 |         17        0.12       72.87
     999199 |        272        1.88       74.75
     999299 |        722        4.98       79.73
     999799 |          1        0.01       79.74
     999919 |        133        0.92       80.65
     999929 |        391        2.70       83.35
     999979 |          1        0.01       83.36
     999989 |          4        0.03       83.39
     999991 |         35        0.24       83.63
     999992 |         84        0.58       84.21
     999997 |          2        0.01       84.22
     999998 |         25        0.17       84.39
     999999 |      2,263       15.61      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. gen priormajor = (regexm(major1, "1"))

. tab priormajor

 priormajor |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |      9,203       63.47       63.47
          1 |      5,296       36.53      100.00
------------+-----------------------------------
      Total |     14,499      100.00

. 
. // Adds weights
. destring weight, force replace
weight contains nonnumeric characters; replaced as double

. gen id = _n

. svyset id [pweight=weight]

      pweight: weight
          VCE: linearized
  Single unit: missing
     Strata 1: <one>
         SU 1: id
        FPC 1: <zero>

. 
. matrix values = J(3, 7, -9)

. 
. // No Prior Major Imprisonment 
. svy: mean priormajor
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1         Number of obs    =    14499
Number of PSUs   =   14499         Population size  =  1226171
                                   Design df        =    14498

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
  priormajor |   .3811885   .0043146      .3727314    .3896456
--------------------------------------------------------------

. matrix temp = e(b)

. matrix values[1, 1] = 1 - temp[1, 1]

. svy: mean priorminor if priormajor == 0
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    9203
Number of PSUs   =    9203          Population size  =  758769
                                    Design df        =    9202

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
  priorminor |   .1965982   .0044796      .1878172    .2053792
--------------------------------------------------------------

. matrix temp = e(b)

. matrix values[1, 2] = temp[1, 1]

. svy: mean priorprobation if priormajor == 0
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    9203
Number of PSUs   =    9203          Population size  =  758769
                                    Design df        =    9202

----------------------------------------------------------------
               |             Linearized
               |       Mean   Std. Err.     [95% Conf. Interval]
---------------+------------------------------------------------
priorprobation |   .5344636   .0055798      .5235259    .5454013
----------------------------------------------------------------

. matrix temp = e(b)

. matrix values[1, 3] = temp[1, 1]

. forvalues i = 0(1)3 {
  2. gen temp = (priorarrests2 == `i')
  3. svy: mean temp if priormajor == 0
  4. matrix temp = e(b)
  5. matrix values[1, 4 + `i'] = temp[1, 1]
  6. drop temp
  7. }
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    9203
Number of PSUs   =    9203          Population size  =  758769
                                    Design df        =    9202

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .2400172   .0047417      .2307224    .2493121
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    9203
Number of PSUs   =    9203          Population size  =  758769
                                    Design df        =    9202

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .1886789   .0043806      .1800919    .1972658
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    9203
Number of PSUs   =    9203          Population size  =  758769
                                    Design df        =    9202

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .1457355   .0039621      .1379689    .1535021
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    9203
Number of PSUs   =    9203          Population size  =  758769
                                    Design df        =    9202

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .3781056   .0054377      .3674464    .3887647
--------------------------------------------------------------

. 
. // No Prior Major or Minor Imprisonment 
. gen temp = (priormajor | priorminor)

. svy: mean temp
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1         Number of obs    =    14499
Number of PSUs   =   14499         Population size  =  1226171
                                   Design df        =    14498

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .5028457   .0044264      .4941694    .5115221
--------------------------------------------------------------

. drop temp

. matrix temp = e(b)

. matrix values[2, 1] = 1 - temp[1, 1]

. svy: mean priorminor if priormajor == 0 & priorminor == 0
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    7482
Number of PSUs   =    7482          Population size  =  609596
                                    Design df        =    7481

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
  priorminor |          0  (omitted)
--------------------------------------------------------------

. matrix temp = e(b)

. matrix values[2, 2] = temp[1, 1]

. svy: mean priorprobation if priormajor == 0 & priorminor == 0
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    7482
Number of PSUs   =    7482          Population size  =  609596
                                    Design df        =    7481

----------------------------------------------------------------
               |             Linearized
               |       Mean   Std. Err.     [95% Conf. Interval]
---------------+------------------------------------------------
priorprobation |   .4821089   .0062283      .4698996    .4943182
----------------------------------------------------------------

. matrix temp = e(b)

. matrix values[2, 3] = temp[1, 1]

. forvalues i = 0(1)3 {
  2. gen temp = (priorarrests2 == `i')
  3. svy: mean temp if priormajor == 0 & priorminor == 0
  4. matrix temp = e(b)
  5. matrix values[2, 4 + `i'] = temp[1, 1]
  6. drop temp
  7. }
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    7482
Number of PSUs   =    7482          Population size  =  609596
                                    Design df        =    7481

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .2972876   .0056632      .2861861    .3083891
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    7482
Number of PSUs   =    7482          Population size  =  609596
                                    Design df        =    7481

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .2003529   .0049932      .1905648    .2101409
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    7482
Number of PSUs   =    7482          Population size  =  609596
                                    Design df        =    7481

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .1455458   .0044086      .1369037     .154188
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    7482
Number of PSUs   =    7482          Population size  =  609596
                                    Design df        =    7481

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .3117447   .0057855      .3004034    .3230859
--------------------------------------------------------------

. 
. // No Prior Major or Minor Imprisonment or Probation
. gen temp = (priormajor | priorminor | priorprobation)

. svy: mean temp
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1         Number of obs    =    14499
Number of PSUs   =   14499         Population size  =  1226171
                                   Design df        =    14498

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .7425282   .0038417      .7349981    .7500584
--------------------------------------------------------------

. drop temp

. matrix temp = e(b)

. matrix values[3, 1] = 1 - temp[1, 1]

. svy: mean priorminor if priormajor == 0 & priorminor == 0 & priorprobation == 0
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    3975
Number of PSUs   =    3975          Population size  =  315704
                                    Design df        =    3974

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
  priorminor |          0  (omitted)
--------------------------------------------------------------

. matrix temp = e(b)

. matrix values[3, 2] = temp[1, 1]

. svy: mean priorprobation if priormajor == 0 & priorminor == 0 & priorprobation == 0
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    3975
Number of PSUs   =    3975          Population size  =  315704
                                    Design df        =    3974

----------------------------------------------------------------
               |             Linearized
               |       Mean   Std. Err.     [95% Conf. Interval]
---------------+------------------------------------------------
priorprobation |          0  (omitted)
----------------------------------------------------------------

. matrix temp = e(b)

. matrix values[3, 3] = temp[1, 1]

. forvalues i = 0(1)3 {
  2. gen temp = (priorarrests2 == `i')
  3. svy: mean temp if priormajor == 0 & priorminor == 0 & priorprobation == 0
  4. matrix temp = e(b)
  5. matrix values[3, 4 + `i'] = temp[1, 1]
  6. drop temp
  7. }
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    3975
Number of PSUs   =    3975          Population size  =  315704
                                    Design df        =    3974

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .5609257    .008574      .5441159    .5777354
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    3975
Number of PSUs   =    3975          Population size  =  315704
                                    Design df        =    3974

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .1786249   .0066445      .1655979    .1916518
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    3975
Number of PSUs   =    3975          Population size  =  315704
                                    Design df        =    3974

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .0936668   .0050801      .0837069    .1036266
--------------------------------------------------------------
(running mean on estimation sample)

Survey: Mean estimation

Number of strata =       1          Number of obs    =    3975
Number of PSUs   =    3975          Population size  =  315704
                                    Design df        =    3974

--------------------------------------------------------------
             |             Linearized
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
        temp |   .1266307   .0057687      .1153207    .1379407
--------------------------------------------------------------

. 
. * This is Table SA 06
. matlist values

             |        c1         c2         c3         c4         c5         c6         c7 
-------------+-----------------------------------------------------------------------------
          r1 |  .6188115   .1965982   .5344636   .2400172   .1886789   .1457355   .3781056 
          r2 |  .4971543          0   .4821089   .2972876   .2003529   .1455458   .3117447 
          r3 |  .2574718          0          0   .5609257   .1786249   .0936668   .1266307 

. 
. log close
      name:  <unnamed>
       log:  /Users/marcmere/Box Sync/Shared_EffectofIncarceration_Pennslyvania/Replication Data/Arrests SA Table 06/Arrests.log
  log type:  text
 closed on:  17 Dec 2016, 10:33:23
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
